All right.
So now we're going to add a script to our barrel, which is going to turn on and off our zombie spawning.
And I have a proximity prompt which is going to trigger an event which is going to make that happen.
Right.
We haven't hooked that up yet.
We just have the action prompt here.
That's a proximity prompt.
I want to take a look at this, but before I do, I'm going to go down to server script service and
I'm going to get my activated on the Z spotter and uncheck it.
Right.
We're going to start with it off right now.
I'm going to play this.
Take a look at my my action prompt.
Yeah.
There it is.
Oh, I should have made my my spawn location closer to the barrel.
There we go.
We don't have very much gas coming out of there.
So that is my proximity prompt.
We can configure this to be a little bit more descriptive.
So let's go ahead and turn us off.
Go back to our action prompt under the barrel.
So barrel lid top action prompt Change the action text to release.
Valve.
There we go.
We should say turn release valve.
Maybe I'll do turn release Valve because you never know which way to turn anything.
Right.
It's going to make the zombies come out or is it going to stop the zombies?
Cool.
And then I'm going to go down here a little bit.
Four hole duration.
I'll make it 2 seconds.
You can make it 2 seconds or 5 seconds.
You want it to be kind of stressful when they're trying to turn it off, right?
Because the zombies are going to be running around and then max activation distance.
That's good at ten.
But I'm also going to turn off what is this line of sight?
Where is our line of sight?
There it is.
Requires line of sight.
I'm going to say no, because sometimes when you're building stuff, you get a part in a way.
And that's frustrating if your character is trying to if your player is trying to stand in front of
it to get the prompt to come up and it can't.
All right.
I think we're good.
Let's go to our lid top.
Hit the little plus sign there.
I had the script.
And then I'm going to call this action.
Z Cool.
We need a variable for our part.
So that's a local part.
That's the lid top, right?
But I'm just going to call a part in case we want to move that script.
So it's going to be script parent.
I'm going to need my proximity prompt.
I will just have prompt because we're only going to have one.
So say part.
We have a variable for the part, which is script parent and on the part we have a prompt and we call
it action prompt.
Cool.
We need a sound to write.
Let's call alarm.
Alarm.
We need alarm sound.
It's going to start going off when we turn on the turn on the Z spanner.
Let's go to our game here.
Go to Toolbox.
Click it.
Models will go to audio and then under audio on a search for alarm.
Ario.
A nuclear arm.
I like that.
All right.
I'm going to insert that click on the part you want to insert this into.
I had lid top insert.
It's going to pop in there.
If it goes somewhere else, you can just drag it under the lid top.
All right.
I'm going to change his name.
It's too long.
I'm just going to call it alarm.
There we go.
Alarm.
Cool.
And I want to make sure it's looped in case it turns off before I'm ready for it to turn off.
So we'll hit looped.
And that way they'll just keep going until we actually say stop.
All right.
Now we go back here and on our part we have an alarm.
There it is.
What else do we need?
We need this activated variable right here.
And it is on my script, which is in server script service.
Little bit inconvenient.
So let's get a variable for server script service source because I'm lazy and we're not going to use
it in the script.
We're just going to get the activated, let's say game get service server, script service.
Cool.
And then when server script service, we're going to get our Z Spanner script because we still need
a variable on that script.
So say Spawn or Z.
Spanner says, Wait for child Z spotter.
All right.
And then finally, this is what we need activated, right?
That's on the Z spanner.
We could just do activated.
But I'm being cautious.
We'll do wait for child activated.
All right.
We need a function to capture the proximity prompt event that triggered event.
So I'm going to call this on release.
Right.
The player will get passed in.
Let's go ahead and capture the event now.
So go down to the bottom and then we're going to get this prompt.
The triggered is the event that when you hold that thing down, it's going to fire connect on release,
Right?
So it's just like a button, really cool.
But it pops up automatically when you get closed.
That's convenient.
All right.
So now in the release, we triggered it.
Two things can happen.
We can either turn it on or we turn it off.
So I'm going to say if activated, right, activate a value because it's a Boolean value, then we have
to turn it off.
It's already on.
So I'm going to say activated dot value will be false.
We're turning it off and there's going to be a sound playing right.
There's going to be an alarm playing.
So I'm going to say alarm.
Colon, stop.
Right.
We haven't turned it on yet, but we will in a second because the other condition in the else right
here is going to be the opposite.
So let's say it is off now.
Somebody turned the valve and it's on.
Right.
So the alarm is going to start playing.
We'll say play.
All right, cool.
Now, the alarm won't start playing if we.
If we go ahead and check this.
Just keep that in mind.
Right.
So make sure it's off, because we'll have to turn the alarm off some on some other way if we have it
as a default behavior for when the game starts.
So you go walking up here, you're like, Oh, look at this.
There's a little bit of green gas in here.
We could actually increase that, right says turn release valve.
Oh, yeah, probably should.
Oh, man.
What's that sound?
That doesn't sound good.
Oh, zombies.
Let me run and run away.
I want to get.
I want to get him underneath that boulder trap.
Because another thing we're going to have to start doing, it's figuring out how to get points for their
deaths.
Right.
So that's coming up to, oh, you know what I want to do in the next video?
I'm going to add stickers to this to decals, because that can be a little bit tricky and people like
to add decals.
So I will see you in the next video.